<?php
function shutdown()
{
    Zend_Session::writeClose(true);
}

register_shutdown_function('shutdown');

if (version_compare(phpversion(), '5.2.0', '<') === true) {
    die('ERROR: Your PHP version is '.phpversion().'. SFS requires PHP 5.2.0 or newer.');
}
//define('APPLICATION_ENV','production');
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));


define('SFS_ROOT_DIR',realpath(dirname(__FILE__) . '/../'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));

require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();

/** Zend_Application */
require_once 'Zend/Application.php';

$res = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini',APPLICATION_ENV);
$arr = $res->toArray() ;
$arr['bootstrap']['path'] = APPLICATION_PATH . '/Installer.php';
$arr['bootstrap']['class'] = 'Sfs_Installer';

// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
$arr
);

$application->bootstrap()->run();